import unittest
import requests


class TestIhrmDept(unittest.TestCase):
    # 添加
    def test01(self):
        url = "http://ihrm-test.itheima.net/api/company/"
        header = {"Content-Type": "application/json",
                  "Authorization": "Bearer ab7ce8fe-db31-4b23-af67-5723c1f9d150"}
        data = {"name": "蛤蛤蛤002", "code": "9020", "pid": "5023"}
        resp = requests.post(url=url, headers=header, json=data)
        print("新增：", resp.json())

    # 查询
    def test02(self):
        url = "http://ihrm-test.itheima.net/api/company/department/1528259802902384640"
        header = {"Authorization": "Bearer ab7ce8fe-db31-4b23-af67-5723c1f9d150"}
        resp = requests.get(url=url, headers=header)
        print("查询", resp.json())

    # 修改
    def test03(self):
        url = "http://ihrm-test.itheima.net/api/company/department/1528259802902384640"
        header = {"Content-Type": "application/json",
                  "Authorization": "Bearer ab7ce8fe-db31-4b23-af67-5723c1f9d150"}
        data = {"name": "蛤蛤蛤003", "code": "9021"}
        resp = requests.put(url=url, headers=header, json=data)
        print("修改：", resp.json())

    # 删除
    def test04(self):
        url = "http://ihrm-test.itheima.net/api/company/department/1528259802902384640"
        header = {"Authorization": "Bearer 6cf6feec-be6c-4009-9b80-d4dbb9dd3b85"}
        resp = requests.delete(url=url, headers=header)
        print("删除", resp.json())

